<template>
  <div class="comment-reply">
    <van-nav-bar :title="comment.reply_count>0?`${comment.reply_count}条回复`:'暂无回复'">
      <van-icon name="cross" slot="left" @click="$emit('close')" />
    </van-nav-bar>
    <div class="allReply">
       <comment-item :comment="comment"/>
      <van-cell title="全部回复" />
      <comment-list type="c" :artId="comment.com_id" :list="commentList"/>
    </div>
    <div class="replyComment">
      <van-button type="default" class="reply-btn" round size="small" @click="showReply=true">写评论</van-button>
    </div>
    <!-- 回复评论弹出层 -->
    <van-popup v-model="showReply" position="bottom">
      <comment-issue :artId="comment.com_id" @addComment="addComment" :articleId="articleId"/>
    </van-popup>
  </div>
</template>

<script>
import commentItem from './comment-item'
import commentList from './comment-list'
import commentIssue from './comment-issue'
export default {
  name: 'commentReply',
  components: {
    commentItem,
    commentList,
    commentIssue
  },
  props: {
    comment: {
      type: Object,
      required: true
    },
    artId: {
      type: [Number, String, Object],
      required: true
    },
    articleId: {
      type: [Number, String, Object],
      required: true
    }
  },
  data () {
    return {
      showReply: false,
      commentList: []
    }
  },
  computed: {},
  watch: {},
  created () {

  },
  mounted () {

  },
  methods: {
    addComment(res) {
      this.showReply = false
      this.comment.reply_count++
      this.commentList.unshift(res.new_obj)
    }
  }
}
</script>

<style scoped lang="less">
.comment-reply {
  .allReply {
    position: fixed;
    top: 92px;
    bottom: 88px;
    left: 0;
    right: 0;
    overflow-y: auto;
  }
  .replyComment {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 88px;
    background-color: #fff;
    border-top: 1px solid #000;
    .reply-btn {
      width: 60%;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
}
</style>
